package org.feng.api;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 日期范围
 *
 * @author feng
 */
@Data
@ApiModel("日期范围")
@NoArgsConstructor
@AllArgsConstructor
public class DateRange {

    @NotNull(message = "起始日期不能为空")
    @ApiModelProperty(name = "start", value = "起始日期", required = true)
    private LocalDate start;

    @NotNull(message = "结束日期不能为空")
    @ApiModelProperty(name = "end",value = "结束日期", required = true)
    private LocalDate end;

    public LocalDateTime startLocalDateTime() {
        return LocalDateTime.of(start, LocalTime.MIN);
    }

    public LocalDateTime endLocalDateTime() {
        return LocalDateTime.of(end, LocalTime.MAX);
    }
}
